package com.projet.ai;

import cn.hutool.http.HttpRequest;

import java.nio.file.Files;
import java.nio.file.Paths;

public class AiTest {
    public static void main(String[] args) {
        try {
            Long start = System.currentTimeMillis();
            String urlString = "https://assistants.edgenets.io/image";
            String  base = "D:\\doc\\南方电网\\ai\\";
            byte[] bytes = Files.readAllBytes(Paths.get(base+"002.jpg"));
            System.out.println("开始访问：" + urlString);
            String response = HttpRequest.post(urlString).timeout(120000)
                    .header("Content-Type", "application/octet-stream")
                    .header("X-API-KEY", "812bec5a6dc8cb83")
                    .body(bytes)
                    .execute().body();
            System.out.println("结束访问：" + urlString+" ,耗时："+(System.currentTimeMillis() - start));
            System.out.println("结果***********************************");
            System.out.println(response);
            Files.write(Paths.get(base+ System.currentTimeMillis() + ".txt"), response.getBytes());
            System.out.println("结果***********************************");
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}
